package com.cms.model;

import java.io.File;
import java.util.Date;
import java.util.List;

import com.cms.plugin.db.Model;
import com.cms.plugin.db.Page;
import com.cms.plugin.db.annotation.Table;


/**
 * s_mail_config model.

将表结构放在此，消除记忆负担
mysql> desc s_admin;

数据库字段名建议使用驼峰命名规则，便于与 java 代码保持一致，如字段名： userId
 */
@SuppressWarnings("serial")
@Table("s_mail_record")
public class MailRecord extends Model<MailRecord>{
	public static final MailRecord dao = new MailRecord();
	
	/**
	 * 所有 sql 写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public Page<MailRecord> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from s_mail_record order by id desc");
	}

	public void addRecord(String toMail, String subject, String content,
			List<File> attachments, boolean b,String toName,int type,String fromEamil) {
		update("insert into s_mail_record(to_mail,content,to_date,success,attachment,from_email,type,to_name,title) values(?,?,?,?,?,?,?,?,?)", toMail,content,new Date(),b?1:0,"",fromEamil,type,toName,subject);
	}


}
